import {
  getData,
  postData,
  putData,
  deleteData,
} from "@/api/common/index";

const baseDefaultAmountConfig = "/api/default-amount-config";

const DefaultAmountConfigUrl = {
  page: "/page",
  url: "",
  queryCode: "/queryCode",
};

export function getDefaultAmountConfigPage(params: any, pageNo: number | null | undefined, pageSize: number | null | undefined): Promise<any> {
  let url = baseDefaultAmountConfig + DefaultAmountConfigUrl.page + "?pageNum=" + (pageNo ? pageNo : 1) + "&pageSize=" + (pageSize ? pageSize : 10);
  return postData(url, params);
}

export function getDefaultAmountConfigDetail(id: number): Promise<any> {
  return getData(baseDefaultAmountConfig + DefaultAmountConfigUrl.url + "?id=" + id);
}

export function deleteDefaultAmountConfig(ids: string): Promise<any> {
  return deleteData(baseDefaultAmountConfig + DefaultAmountConfigUrl.url + "?ids=" + ids);
}

export function addOrEditDefaultAmountConfig(
  method: string,
  params: any
): Promise<any> {
  if ("put" == method) {
    return putData(baseDefaultAmountConfig + DefaultAmountConfigUrl.url, params);
  } else {
    return postData(baseDefaultAmountConfig + DefaultAmountConfigUrl.url, params);
  }
}

// 查询默认金额配置
export function getDefaultAmountConfigQueryCode(params: any): Promise<any> {
  return getData(baseDefaultAmountConfig + DefaultAmountConfigUrl.queryCode, params);
}